const accessList = [
  {
    accessKey: 'UBhF1SWNZQKzBIDLvJIA',
    accessSecret: '1FFawccMatV00SxSFHU1n2zCocobLekuLkV4ELC4A',
    createTime: '2024-06-28T00:20:09.000+00:00',
    disable: 0,
    lastUsedTime: null,
  },
  {
    accessKey: 'gqb1ll0_qvVfksBmBmsd',
    accessSecret: '5a00Nax2e1drhinkjyppgkapLXijjIgGBx_AlpsSZ',
    createTime: `2024-06-20T02:31:09.000+00:00`,
    disable: 0,
    lastUsedTime: `2024-06-24T02:31:09.000+00:00`,
  },
  {
    accessKey: 'gqb1ll0_qvVfksBmBmssssd',
    accessSecret: '5a00Nax2e1drhinkjyppgkapLXijjIgGBx_AlpsSZ',
    createTime: `2024-06-24T01:31:09.000+00:00`,
    disable: 1,
    lastUsedTime: `2024-06-24T02:31:09.000+00:00`,
  },
];

const applyRes = {
  accessKey: 'gqb1ll0_qvVfksBmBmsd',
  accessSecret: '5a00Nax2e1drhlnkjyppgkapLXijIgGBx_AlpsSZ',
  createTime: '2024-06-28T10:20:09.000+00:00',
  disable: 1,
  lastUsedTime: `2024-06-24T02:31:09.000+00:00`,
};

export default {
  'POST /api/v1/access/list': (
    req: {
      body: {
        userId: string;
      };
    },
    res: any,
  ) => {
    res.json({
      success: true,
      code: 200,
      message: '获取access列表成功',
      data: accessList,
      errorCode: 0,
    });
  },
  'POST /api/v1/access/disable': (req: any, res: any) => {
    res.json({
      success: true,
      errorCode: 0,
      data: true,
      code: 200,
      message: '禁用成功',
    });
  },
  'POST /api/v1/access/create': (
    req: {
      body: {
        userId: string;
      };
    },
    res: any,
  ) => {
    res.json({
      success: true,
      errorCode: 0,
      data: applyRes,
      code: 200,
      message: '获取引擎列表成功',
    });
  },
  'POST /api/v1/engine/find': (
    req: {
      body: {
        userId: string;
        accessKey: string;
      };
    },
    res: any,
  ) => {
    let { accessKey } = req.body;
    let access = accessList.find((item) => item.accessKey === accessKey);
    // 添加跨域请求头
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.json({
      success: true,
      errorCode: 0,
      data: access,
      code: 200,
      message: '获取引擎列表成功',
    });
    res.end('ok');
  },
};
